package com.hddf.project.auth.dao;

import java.util.List;
import java.util.Map;

import com.hddf.project.auth.pojos.User;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;

public interface UserDao_MongoDB {
	
	public int getUserTotalCount(int isopen,DBCollection c);
	
	public List<DBObject> getUserList(String start,String limit,int isopen,DBCollection c);
	
	public boolean addWebTokenAndAESKey(BasicDBObject obj,DBCollection c);
	
	public void addAppKeyPair(int user_id,String pubk,Map prik_map,DBCollection c);
	
	//public String addWebToken(String username,long webtoken_deadline,DBCollection c);
	
	//public String addWebToken(int user_id,long webtoken_deadline,DBCollection c);
	
	public String addAppToken(String username,long apptoken_deadline,DBCollection c);
	
	public String addAppToken(int user_id,long apptoken_deadline,DBCollection c);
	
	public DBObject getUserByWebToken(String web_token,DBCollection c);
	
	public DBObject getDBObjectUserById(int id, DBCollection c) ;
	
	public DBObject getUserByAppToken(String app_token,DBCollection c);
	
	public DBObject getPubKeyByAppToken(String app_token, DBCollection c);
	
	/**
	 * 根据令牌获取用户的简要信息 (用户名,私钥,用户id,令牌截止时间)
	 * @param app_token
	 * @param c
	 * @return
	 */
	public DBObject getSimpleUserByAppToken(String app_token,DBCollection c);
	
	/**
	 * 根据令牌获取用户的简要信息 (用户名,aes_key,用户id,令牌截止时间)
	 * @param web_token
	 * @param c
	 * @return
	 */
	public DBObject getSimpleUserByWebToken(String web_token,DBCollection c);
	
	public boolean save(User user,DBCollection c);
	
	public boolean delete(int id,DBCollection c);
	
	public boolean update(User user,DBCollection c);
	
	public boolean update(DBObject obj,DBCollection c);
	
	public boolean updatePassword(User user, DBCollection c);
	
	public boolean updateWebToken(DBObject obj, DBCollection c);
	
	public User getUserByName(String name,DBCollection c);
	
	public User getUserByFullName(String fullname, DBCollection c);
	
	public User getUserByUser_No(String user_no, DBCollection c);
	
	public User getUserById(int id,DBCollection c);
	
	public boolean setUserOn(int id,DBCollection c);
	
	public boolean setUserOff(int id,DBCollection c);
}
